//
//  NSString+MJ.h
//  新浪微博
//
//  Created by apple on 13-10-27.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (DF)

+ (instancetype)localizedStringWithDateSinceNow:(NSDate*)date;

- (NSString *)fileAppend:(NSString *)append;

-(id)json;

// 过滤所有HTMl元素
-(NSString*)stringByFilterHtml;

- (NSString *)md5Hex;
/**
 *  是否空字符串
 *
 *  @return 如果字符串为nil或者长度为0返回YES
 */
- (BOOL)isEmpty;


- (BOOL)isEmail;


/**
 *  清空字符串中的空白字符
 *
 *  @return 清空空白字符串之后的字符串
 */
- (NSString *)trimString;


/**
 *  返回沙盒中的文件路径
 *
 *  @return 返回当前字符串对应在沙盒中的完整文件路径
 */
- (NSString *)documentsPath;

/**
 *  写入系统偏好
 *
 *  @param key 写入键值
 */
- (void)saveToUserDefaults:(NSString *)key;


// 验证是否匹配正则表达式
-(BOOL)matchesWithPattern:(NSString*)pattern;



// 处理小数位
+ (NSString *)roundUpNumber:(float)number scale:(short)scale;
+ (NSString *)roundDownNumber:(float)number scale:(short)scale;
+ (NSString *)roundPlainNumber:(float)number scale:(short)scale;
+ (NSString *)roundBankersNumber:(float)number scale:(short)scale;
+ (NSString *)roundNumber:(float)number scale:(short)scale roundingMode:(NSRoundingMode)roundingMode;

- (NSString *)encodeToPercentEscapeString;


+ (NSString *)sha1:(NSString *)str;

- (NSString*)md5;

- (NSString*)fileNameMD5WithExtension:(NSString*)extension;

/**
 * 与当前时间戳比较
 * @return	间隔描述文本, 日期+时间
 */
+ (NSString *)datetimeStrWithTimeInterval:(NSTimeInterval)timeInterval;

/**
 * 2015-10-20 13:58:40 转友好时间
 */
+ (NSString *)friendTimeWithTimeStr:(NSString *)theDate;
@end
